<?php

namespace Admin/Model;

use Think/Model;

class NewsModel extends Model {
	
	/**
	 * 创建资讯
	 */	
	public function createNew($data){
		$News = M('news');
		$News->create($data);
	}
	
	/**
	 * 更新资讯
	 */
	public function updateNew($id, $data){
		$News = M('news');
		return $News->where('id='.$id)->save($data); // 根据条件更新记录
	}
	
	/**
	 * 删除资讯
	 * 删除主键为$id的数据, 支持批量删除 1,2,4
	 */
	public function deleteNew($ids){
		$News = M('news');
		return $News->where($ids)->delete(); // 根据条件删除数据
	}
	
	
	/**
	 * 获取所有数据
	 */
	public function getNews($limit, $offset){
		$News = M('news');
		return $News->select();
	}
	
	/**
	 * 根据新闻ID查询新闻详情
	 */
	public function findNewsById($id){
		$News = M('news');
		return $News->where('id='.$id)->select();
	}
}
